package ch.fhnw.apsi.services;

import ch.fhnw.apsi.Page;
import ch.fhnw.apsi.beans.ErrorMessage;
import ch.fhnw.apsi.beans.Success;

public class ServiceResult {
  private Object bean;
  private Page page;

  public ServiceResult(final Object bean, final Page page) {
    super();
    this.setBean(bean);
    this.setPage(page);
  }

  public static ServiceResult error(final Integer status, final String error) {
    return new ServiceResult(new ErrorMessage(status, error), Page.ERROR);
  }

  public static ServiceResult success(final String msg) {
    return new ServiceResult(new Success(msg), Page.SUCCESS);
  }

  public Object getBean() {
    return this.bean;
  }

  public Page getPage() {
    return this.page;
  }

  public void setPage(final Page page) {
    this.page = page;
  }

  public void setBean(final Object bean) {
    this.bean = bean;
  }

}
